import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:interview/components/status_bar_warpper.dart';
import 'package:interview/controller/user_controller.dart';
import 'package:interview/theme/app_colors.dart';
import 'package:interview/views/mine/components/mine_menu.dart';
import 'package:interview/views/mine/components/mine_setting.dart';
import 'package:interview/views/mine/components/mine_userinfo.dart';

class Mine extends StatefulWidget {
  const Mine({super.key});

  @override
  State<Mine> createState() => _MineState();
}

class _MineState extends State<Mine>  {

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }


  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context).extension<AppColors>()!;
    return StatusBarWrapper(
      statusBarColor: theme.subjectMix3!,
      statusBarIconBrightness: Theme.of(context).brightness == Brightness.dark ? Brightness.light : Brightness.dark,
      child: SafeArea(
        child: Container(
          width: double.infinity,
          padding: const EdgeInsets.only(top: 16 , left: 16 , right: 16),
          decoration: BoxDecoration(
            gradient: RadialGradient(
              center: Alignment.topCenter, // 渐变中心点
              radius: 2.0,
              colors: [
                theme.subjectMix3!, // 状态栏颜色
                theme.subjectMix2!, // 容器背景颜色
              ],
              stops:const [0.3, 1.0], // 设置颜色过渡的位置比例
            ),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisSize: MainAxisSize.min,
            children: [
              // 个人信息区 使用 GetX 的 Obx 来监听用户信息变化
              GetX<UserController>(
                builder: (userController) {
                  final user = userController.getUser();
                  return MineUserinfo(
                    theme: theme,
                    user: user, // 显示最新的用户信息
                  );
                },
              ),
              const SizedBox(height: 36),
              // 菜单区
              MineMenu(theme:theme),
              const SizedBox(height: 36),
              // 设置区
              MineSetting(theme:theme),
            ],
          ),
        )
      ),
    );
  }
}